from django.shortcuts import render
from django.views import View

from courses.models import Course
from organization.models import CourseOrg
from users.models import Banner


class IndexView(View):
    def get(self,request):
        all_banners = Banner.objects.all()
        courses = Course.objects.all()
        course_orgs = CourseOrg.objects.all()
        context ={
            'all_banners': all_banners,
            'courses': courses,
            'banner_courses': courses,
            'course_orgs': course_orgs, }
        return render(request, 'index.html', context)
        # all_banners 获取轮播图表(Banner)所有轮播图数据
        # courses  获取课程信息表(Course)中的课程信息数据
        # banner_courses 获取课程信息表中(Course)的课程信息数据 和上面数据一样
        # course_orgs  获取课程学校表(CourseOrg)中的数据